package com.kingdee.eas.custom.rcbudget.util;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.swing.KDPromptSelector;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.bos.ui.face.IUIFactory;
import com.kingdee.bos.ui.face.IUIWindow;
import com.kingdee.bos.ui.face.UIFactory;
import com.kingdee.eas.common.client.OprtState;
import com.kingdee.eas.common.client.UIContext;
import com.kingdee.eas.common.client.UIFactoryName;
import com.kingdee.eas.custom.rcbudget.client.ContractTypeF7UI;
import com.kingdee.eas.util.client.ExceptionHandler;

public class ContractTypePromptSelector implements KDPromptSelector{

    protected IUIWindow f7UI;
    protected CoreUIObject ui;

    public ContractTypePromptSelector(CoreUIObject ui)
    {
        this.ui = ui;
    }

    public void show()
    {
        UIContext context = new UIContext(ui);
        context.put("CANRESIZE", Boolean.FALSE);
        IUIFactory uiFactory = null;
        try
        {
            uiFactory = UIFactory.createUIFactory(UIFactoryName.MODEL);
            f7UI = uiFactory.create(ContractTypeF7UI.class.getName(), context, null, OprtState.VIEW);
            f7UI.show();
        }
        catch(BOSException ex)
        {
            ExceptionHandler.handle(ui, ex);
        }
    }

    public boolean isCanceled()
    {
    	ContractTypeF7UI f7UIObject = (ContractTypeF7UI)f7UI.getUIObject();
        return f7UIObject.isCancel();
    }

    public Object getData()
    {
        try
        {
            ContractTypeF7UI f7UIObject = (ContractTypeF7UI)f7UI.getUIObject();
            return f7UIObject.getData();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            ExceptionHandler.handle(ui, e);
            return null;
        }
    }
}
